<?php
session_start();
require_once('include/connect.inc.php');
$max = mysql_query("select max(match_set) from tb_question");
	$total_max = mysql_result($max,0);
	$now_match_set = $total_max+1;
	//ส่วนของการเพิ่มคำถามจับคู่แบบชุด
	$question=$_POST[num_ques];
	$choice=$_POST[num_cho];		
	$ques=$_POST[question];
	$cho=$_POST[choice];
	print_r($ques);
		for($i=0;$i<=$num_cho-1;$i++){
			if($i<=$question-1){
			echo $question;
			echo $i;
					$strSql="INSERT INTO tb_question (question_detail,match_set) VALUES ('".$ques[$i]."','$now_match_set')";
						execute($strSql);
						$query= query("SELECT question_id FROM tb_question order by question_id desc limit 0,1");
							while ($rs = fetch_array($query)) {
							$now_q_id=$rs['question_id'];
								}
								$strSql="INSERT INTO tb_choice (choice_detail,question_id,match_set) VALUES ('".$cho[$i]."','$now_q_id','$now_match_set')";
									execute($strSql);
									}else{
									$strSql="INSERT INTO tb_choice (choice_detail,question_id,match_set) VALUES ('".$cho[$i]."',0,'$now_match_set')";
										execute($strSql);
									}
							}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Model Test Program</title>
</head>
<body>
</body>
</html>
